import {Component, OnInit} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router";
import {AppConstants, Components} from "../constants/constants";

@Component({
  selector:'app-root',
  templateUrl: './dispatcher.component.html'
})
export class DispatcherComponent implements OnInit {

  constructor(
    private router : Router,
    private route : ActivatedRoute
  ) { }

  ngOnInit() {
    this.dispatch();
  }

  private dispatch(){
    this.route.data.subscribe(
      (data:{dispatcher:string}) => {
        let portal = data.dispatcher;
        if(null != portal){
          this.router.navigateByUrl(portal);
          // this.router.navigate([portal]);
        }else{
          this.router.navigate([Components.authenComponent]);
        }
      }
    );
  }
}
